#!/usr/bin/python
# -*- mode:python; coding:utf-8 -*-

import cv

c = cv.CreateCameraCapture(0)      # First device (usually /dev/video0)

cv.NamedWindow("Test 01")          # Window to show frames
cv.StartWindowThread()             # Event Loop on other thread

while True:
    f = cv.QueryFrame(c)           # Retrieve a Frame from camera
    if not f: break

    cv.ShowImage("Test 01", f)     # Show captured frame on Window
    d = 1000 / 30                  # Delay (to get 30 fps)
    k = cv.WaitKey(d)
    if k != -1: break              # Press any key to exit

